package com.yike.user.controller;

import com.yike.user.entity.ShopGarrisonRecord;
import com.yike.user.service.ShopGarrisonRecordService;
import lombok.extern.slf4j.Slf4j;
import com.yike.user.param.ShopGarrisonRecordPageParam;
import com.yike.common.base.BaseController;
import com.yike.common.api.ApiResult;
import com.yike.common.pagination.Paging;
import com.yike.common.api.IdParam;
import com.yike.common.log.Module;
import com.yike.common.log.OperationLog;
import com.yike.common.enums.OperationLogType;
import com.yike.common.api.Add;
import com.yike.common.api.Update;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 店铺值守记录表 控制器
 *
 * @author Sakura
 * @since 2024-09-06
 */
@Slf4j
@RestController
@RequestMapping("/shopGarrisonRecord")
@Module("user")
@Api(value = "店铺值守记录表API", tags = {"店铺值守记录表"})
@ApiIgnore
public class ShopGarrisonRecordController extends BaseController {

    @Autowired
    private ShopGarrisonRecordService shopGarrisonRecordService;

    /**
     * 添加店铺值守记录表
     */
    @PostMapping("/add")
    @OperationLog(name = "添加店铺值守记录表", type = OperationLogType.ADD)
    @ApiOperation(value = "添加店铺值守记录表", response = ApiResult.class)
    public ApiResult<Boolean> addShopGarrisonRecord(@Validated(Add.class) @RequestBody ShopGarrisonRecord shopGarrisonRecord) throws Exception {
        boolean flag = shopGarrisonRecordService.saveShopGarrisonRecord(shopGarrisonRecord);
        return ApiResult.result(flag);
    }

    /**
     * 修改店铺值守记录表
     */
    @PostMapping("/update")
    @OperationLog(name = "修改店铺值守记录表", type = OperationLogType.UPDATE)
    @ApiOperation(value = "修改店铺值守记录表", response = ApiResult.class)
    public ApiResult<Boolean> updateShopGarrisonRecord(@Validated(Update.class) @RequestBody ShopGarrisonRecord shopGarrisonRecord) throws Exception {
        boolean flag = shopGarrisonRecordService.updateShopGarrisonRecord(shopGarrisonRecord);
        return ApiResult.result(flag);
    }

    /**
     * 删除店铺值守记录表
     */
    @PostMapping("/delete/{id}")
    @OperationLog(name = "删除店铺值守记录表", type = OperationLogType.DELETE)
    @ApiOperation(value = "删除店铺值守记录表", response = ApiResult.class)
    public ApiResult<Boolean> deleteShopGarrisonRecord(@PathVariable("id") Long id) throws Exception {
        boolean flag = shopGarrisonRecordService.deleteShopGarrisonRecord(id);
        return ApiResult.result(flag);
    }

    /**
     * 获取店铺值守记录表详情
     */
    @GetMapping("/info/{id}")
    //@OperationLog(name = "店铺值守记录表详情", type = OperationLogType.INFO)
    @ApiOperation(value = "店铺值守记录表详情", response = ShopGarrisonRecord.class)
    public ApiResult<ShopGarrisonRecord> getShopGarrisonRecord(@PathVariable("id") Long id) throws Exception {
        ShopGarrisonRecord shopGarrisonRecord = shopGarrisonRecordService.getById(id);
        return ApiResult.ok(shopGarrisonRecord);
    }

    /**
     * 店铺值守记录表分页列表
     */
    @PostMapping("/getPageList")
    //@OperationLog(name = "店铺值守记录表分页列表", type = OperationLogType.PAGE)
    @ApiOperation(value = "店铺值守记录表分页列表", response = ShopGarrisonRecord.class)
    public ApiResult<Paging<ShopGarrisonRecord>> getShopGarrisonRecordPageList(@Validated @RequestBody ShopGarrisonRecordPageParam shopGarrisonRecordPageParam) throws Exception {
        Paging<ShopGarrisonRecord> paging = shopGarrisonRecordService.getShopGarrisonRecordPageList(shopGarrisonRecordPageParam);
        return ApiResult.ok(paging);
    }

}

